Conversation
Adds a WebSocket server that lets browser-based EO clients connect directly to the game server without needing an external ws proxy. Uses IXWebSocket (v11.4.5) as the underlying library, pulled in automatically at cmake configure time when enabled. The feature is completely opt-in: - Build with: --websocket ON (or -DEOSERV_WANT_WEBSOCKET=ON) - Enable at runtime: WebSocketEnabled = yes in server.ini - Configure the port: WebSocketPort = 8082 (default) When disabled (the default), there is zero impact on the existing build or runtime behavior.
| eoserv_config_default(config, "ThreadPoolThreads" , 0); | ||
| eoserv_config_default(config, "AutoCreateDatabase" , false); | ||
| eoserv_config_default(config, "WorldDumpFile" , "./world.bak.json"); | ||
| eoserv_config_default(config, "WebSocketEnabled" , false); |
There was a problem hiding this comment.
Let's make this default enabled, I want web sockets to be a native feature not an optional addon
|
|
||
| this->UpdateConfig(); | ||
|
|
||
| #ifdef WEBSOCKET_SUPPORT |
There was a problem hiding this comment.
Remove the CMake arg and the #ifdef guards, this should be always enabled
| } | ||
| } | ||
|
|
||
| void EOServer::OnClientRemoved(Client *client) |
There was a problem hiding this comment.
I'm not seeing where this is called. What is this used for? Can BuryTheDead have a call into the wsserver that does something similar?
| EOClient *client = static_cast<EOClient *>(rawclient); | ||
|
|
||
| if (client->Connected() && !client->Accepted() && client->start + delay < now) | ||
| if (client->Connected() && !client->Accepted() && !client->IsWebSocket() && client->start + delay < now) |
There was a problem hiding this comment.
I was hoping to have it so that all clients (both regular socket clients and web socket clients) could be in the same collection so that the implementation could handle stuff like this (i.e. client->IsWebSocket() check should not be necessary since the client method implementations can just handle this transparently). Is it possible to rearchitect the change around that design goal?
| virtual ~Server(); | ||
| virtual void OnClientRemoved(Client *) {} | ||
|
|
||
| virtual ~Server(); |
| return false; | ||
| } | ||
|
|
||
| bool WSClient::Upload(FileType type, int id, InitReply init_reply) |
There was a problem hiding this comment.
Can this be abstracted differently so there's no duplication between regular socket and web socket implementation? I'm guessing the only difference is in how the data is sent; the base class should call a virtual method that this class overrides with the websocket send logic.
Something like this
EOClient::Upload(args) {
/* base implementation that builds/encodes the packet */
this->SendFile(data);
}
EOClient::SendFile(const std::string& data) {
// regular socket send
}
WSClient::SendFile(const std::string& data) {
ws_send(combined);
}| return true; | ||
| } | ||
|
|
||
| void WSClient::Send(const PacketBuilder &builder) |
There was a problem hiding this comment.
Same here, see if you can deduplicate the code using a similar method as described above
Adds a WebSocket to Etheos compadable with EOWeb
Uses IXWebSocket (v11.4.5) as the underlying library, pulled in automatically at cmake configure time when enabled.
The feature is completely opt-in: (as requested)
When disabled (the default), there is zero impact on the existing build or runtime behavior.